<?php
require_once("../../class2.php");
		$user_id = USERID;
		$user_name = USERNAME;
require_once("./includes/require_all.php");

	$keyword= trim($_POST['keyword']);
	$words= explode(" ", $keyword);
	$count= count($words);
	unset($words);

$keyword=urlencode($keyword);

if (isset($_POST['direction_dir-bg'])) {
		$place="dirbg";
		$redirectURL= "http://search.dir.bg/search.php?textfield=$keyword&vid=15";
		if ($count>2) {$redirectURL="";}
}
elseif (isset($_POST['direction_urbandict'])) {
		$place="urbandict";
		$redirectURL= "http://www.urbandictionary.com/define.php?term=$keyword";
		if ($count>10) {$redirectURL="";}
}
elseif (isset($_POST['direction_google'])) {
		$place="google";
		$redirectURL= "http://www.google.bg/#&hl=bg&q=$keyword&pbx=1&oq=$keyword";
		if ($count>25) {$redirectURL="";}
}
elseif (isset($_POST['direction_wiki'])) {
		$place="wikipedia";
		$redirectURL= "http://en.wikipedia.org/wiki/Special:Search?search=$keyword&go=Go";
		if ($count>10) {$redirectURL="";}
}
elseif (isset($_POST['direction_gtranslate'])) {
		$place="gtranslate";
		$redirectURL= "http://translate.google.bg/#auto|bg|$keyword";
}
elseif (isset($_POST['direction_thefreedict'])) {
		$place="thefreedict";
		$redirectURL= "http://www.thefreedictionary.com/$keyword";
}
elseif (isset($_POST['direction_chitankadict'])) {
		$place="chitankadict";
		$redirectURL= "http://rechnik.chitanka.info/w/$keyword";
}

CMS_activitySave("redirect.php?search&place=$place");
	
if ($redirectURL!=="") {
		echo "<meta http-equiv='refresh' content='0;$redirectURL' />";
}
else {
	require_once(HEADERF);
	ramka("open");
	echo "<br><center class='unselectable'><span style='color:red;'>Системата прецени, че заявката ви съдържа твърде голям брой думи за избраната търсачка.<br>Поради тази причина, заявката не беше изпълнена.</span></center><br>";
	ramka("close");
	require_once(FOOTERF);
}
?>